package com.flejay.dreamrecruiter.tools;

import java.text.Normalizer;

public final class BlockSizerTool {

	private BlockSizerTool(){
		super();
	}
	
	/**
	 * Compute the content to count the size without any space character
	 * @param content
	 * @return
	 */
	public static float calculateSize(final String content){
		String contentPrepared = content.replaceAll("\\s", "");
		return contentPrepared.length();
	}
	
	/**
	 * Figure out if the block is overSized or not with 30% margin error
	 * 
	 * @param size
	 * @param globalSize
	 * @param sizeO
	 * @return
	 */
	public static boolean isOverSized(float size, float globalSize, float sizeO){
		return size >= ( (globalSize * sizeO) );
	}

	/**
	 * After avoiding all non ASCII codes and all whiteSpaces return the number of chars contained in content
	 * 
	 * @param content
	 * @return
	 */
	public static float calculateTotalSize(final String content) {
		String contentPrepared = Normalizer.normalize(content, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
		contentPrepared = contentPrepared.replaceAll("\\s", "");
		return contentPrepared.length() * (float) 1.62;
	}
}
